home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / doom / quake2.zip / TF1_2SRC.ZIP / QUAKE / FORTRESS / SOURCE / PLAYER.QC < prev    next >
Text File  |  1996-09-10  |  24KB  |  853 lines

  1. /*
  2.     Heavily Modified for TeamFortress V1.2
  3.     Robin Walker, John Cook
  4. */
  5. // Prototypes
  6. void() bubble_bob;
  7. void() W_FireAssaultCannon;
  8.  
  9. // TeamFortress Prototypes
  10. void() BioInfection_Decay;
  11. void() TeamFortress_RemoveTimers;
  12.  
  13. /*
  14. ==============================================================================
  15.  
  16. PLAYER
  17.  
  18. ==============================================================================
  19. */
  20.  
  21. $cd /raid/quake/id1/models/player_4
  22. $origin 0 -6 24
  23. $base base        
  24. $skin skin
  25.  
  26. //
  27. // running
  28. //
  29. $frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
  30.  
  31. $frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
  32.  
  33. //
  34. // standing
  35. //
  36. $frame stand1 stand2 stand3 stand4 stand5
  37.  
  38. $frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
  39. $frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
  40.  
  41.  
  42. //
  43. // pain
  44. //
  45. $frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
  46.  
  47. $frame pain1 pain2 pain3 pain4 pain5 pain6
  48.  
  49.  
  50. //
  51. // death
  52. //
  53.  
  54. $frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
  55. $frame axdeth7 axdeth8 axdeth9
  56.  
  57. $frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
  58. $frame deatha9 deatha10 deatha11
  59.  
  60. $frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
  61. $frame deathb9
  62.  
  63. $frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
  64. $frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
  65.  
  66. $frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
  67. $frame deathd8 deathd9
  68.  
  69. $frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
  70. $frame deathe8 deathe9
  71.  
  72. //
  73. // attacks
  74. //
  75. $frame nailatt1 nailatt2
  76.  
  77. $frame light1 light2
  78.  
  79. $frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
  80.  
  81. $frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
  82.  
  83. $frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
  84.  
  85. $frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
  86.  
  87. $frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
  88.  
  89. $frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
  90.  
  91.  
  92. /*
  93. ==============================================================================
  94. PLAYER
  95. ==============================================================================
  96. */
  97. void() player_touch =
  98. {
  99.     local entity Bio;
  100.  
  101.     if (self.tfstate & TFSTATE_INFECTED)
  102.     {
  103.         if (other.classname == "player")
  104.         {
  105.             // may sure other player is not already infected
  106.             if (!(other.tfstate & TFSTATE_INFECTED))
  107.             {
  108.                 // can't infect the medic
  109.                 if (other.playerclass != PC_MEDIC)
  110.                 {
  111.                     // infect 'em
  112.                     Bio = spawn ();
  113.                     Bio.nextthink = 2;
  114.                     Bio.think = BioInfection_Decay;
  115.                     Bio.owner = other;
  116.                     Bio.classname = "timer";
  117.                     Bio.enemy = self;
  118.                     Bio.tfstate = TFSTATE_ALTKILL;
  119.                     Bio.altkillweapon = AK_BIOWEAPON;
  120.                     
  121.                     other.tfstate = other.tfstate | TFSTATE_INFECTED;
  122.  
  123.                     other.touch = player_touch;
  124.                             
  125.                     sprint(other, "You have been infected by ");
  126.                     sprint(other, self.netname);
  127.                     sprint(other, "!\n");
  128.                     sprint(self, "You have infected ");
  129.                     sprint(self, other.netname);
  130.                     sprint(self, "!\n");
  131.                 }                
  132.             }
  133.         }
  134.     }
  135. };
  136.  
  137. void() player_run;
  138.  
  139. void()    player_stand1 =[    $axstnd1,    player_stand1    ]
  140. {
  141.     self.weaponframe=0;
  142.     if (self.velocity_x || self.velocity_y)
  143.     {
  144.         self.walkframe=0;
  145.         player_run();
  146.         return;
  147.     }
  148.  
  149.     if (self.weapon == IT_AXE)
  150.     {
  151.         if (self.walkframe >= 12)
  152.             self.walkframe = 0;
  153.         self.frame = $axstnd1 + self.walkframe;
  154.     }
  155.     else
  156.     {
  157.         if (self.walkframe >= 5)
  158.             self.walkframe = 0;
  159.         self.frame = $stand1 + self.walkframe;
  160.     }
  161.     self.walkframe = self.walkframe + 1;    
  162. };
  163.  
  164. void()    player_run =[    $rockrun1,    player_run    ]
  165. {
  166.     self.weaponframe=0;
  167.     if (!self.velocity_x && !self.velocity_y)
  168.     {
  169.         self.walkframe=0;
  170.         player_stand1();
  171.         return;
  172.     }
  173.  
  174.     if (self.weapon == IT_AXE)
  175.     {
  176.         if (self.walkframe == 6)
  177.             self.walkframe = 0;
  178.         self.frame = $axrun1 + self.walkframe;
  179.     }
  180.     else
  181.     {
  182.         if (self.walkframe == 6)
  183.             self.walkframe = 0;
  184.         self.frame = self.frame + self.walkframe;
  185.     }
  186.     self.walkframe = self.walkframe + 1;
  187. };
  188.  
  189.  
  190. void()    player_shot1 =    [$shotatt1, player_shot2    ] {self.weaponframe=1;
  191. self.effects = self.effects | EF_MUZZLEFLASH;};
  192. void()    player_shot2 =    [$shotatt2, player_shot3    ] {self.weaponframe=2;};
  193. void()    player_shot3 =    [$shotatt3, player_shot4    ] {self.weaponframe=3;};
  194. void()    player_shot4 =    [$shotatt4, player_shot5    ] {self.weaponframe=4;};
  195. void()    player_shot5 =    [$shotatt5, player_shot6    ] {self.weaponframe=5;};
  196. void()    player_shot6 =    [$shotatt6, player_run    ] {self.weaponframe=6;};
  197.  
  198. void()    player_autorifle1 =    [$shotatt1, player_autorifle2    ] {self.weaponframe=1;
  199. self.effects = self.effects | EF_MUZZLEFLASH;};
  200. void()    player_autorifle2 =    [$shotatt2, player_autorifle3    ] {self.weaponframe=2;};
  201. void()    player_autorifle3 =    [$shotatt6, player_run    ] {self.weaponframe=6;};
  202.  
  203. void()    player_axe1 =    [$axatt1, player_axe2    ] {self.weaponframe=1;};
  204. void()    player_axe2 =    [$axatt2, player_axe3    ] {self.weaponframe=2;};
  205. void()    player_axe3 =    [$axatt3, player_axe4    ] {self.weaponframe=3;W_FireAxe();};
  206. void()    player_axe4 =    [$axatt4, player_run    ] {self.weaponframe=4;};
  207.  
  208. void()    player_axeb1 =    [$axattb1, player_axeb2    ] {self.weaponframe=5;};
  209. void()    player_axeb2 =    [$axattb2, player_axeb3    ] {self.weaponframe=6;};
  210. void()    player_axeb3 =    [$axattb3, player_axeb4    ] {self.weaponframe=7;W_FireAxe();};
  211. void()    player_axeb4 =    [$axattb4, player_run    ] {self.weaponframe=8;};
  212.  
  213. void()    player_axec1 =    [$axattc1, player_axec2    ] {self.weaponframe=1;};
  214. void()    player_axec2 =    [$axattc2, player_axec3    ] {self.weaponframe=2;};
  215. void()    player_axec3 =    [$axattc3, player_axec4    ] {self.weaponframe=3;W_FireAxe();};
  216. void()    player_axec4 =    [$axattc4, player_run    ] {self.weaponframe=4;};
  217.  
  218. void()    player_axed1 =    [$axattd1, player_axed2    ] {self.weaponframe=5;};
  219. void()    player_axed2 =    [$axattd2, player_axed3    ] {self.weaponframe=6;};
  220. void()    player_axed3 =    [$axattd3, player_axed4    ] {self.weaponframe=7;W_FireAxe();};
  221. void()    player_axed4 =    [$axattd4, player_run    ] {self.weaponframe=8;};
  222.  
  223. // newstuff
  224.  
  225. void()    player_medikit1 =    [$axatt1, player_medikit2    ] {self.weaponframe=1;};
  226. void()    player_medikit2 =    [$axatt2, player_medikit3    ] {self.weaponframe=2;};
  227. void()    player_medikit3 =    [$axatt3, player_medikit4    ] {self.weaponframe=3;W_FireMedikit();};
  228. void()    player_medikit4 =    [$axatt4, player_run    ] {self.weaponframe=4;};
  229.  
  230. void()    player_medikitb1 =    [$axattb1, player_medikitb2    ] {self.weaponframe=5;};
  231. void()    player_medikitb2 =    [$axattb2, player_medikitb3    ] {self.weaponframe=6;};
  232. void()    player_medikitb3 =    [$axattb3, player_medikitb4    ] {self.weaponframe=7;W_FireMedikit();};
  233. void()    player_medikitb4 =    [$axattb4, player_run    ] {self.weaponframe=8;};
  234.  
  235. void()    player_medikitc1 =    [$axattc1, player_medikitc2    ] {self.weaponframe=1;};
  236. void()    player_medikitc2 =    [$axattc2, player_medikitc3    ] {self.weaponframe=2;};
  237. void()    player_medikitc3 =    [$axattc3, player_medikitc4    ] {self.weaponframe=3;W_FireMedikit();};
  238. void()    player_medikitc4 =    [$axattc4, player_run    ] {self.weaponframe=4;};
  239.  
  240. void()    player_medikitd1 =    [$axattd1, player_medikitd2    ] {self.weaponframe=5;};
  241. void()    player_medikitd2 =    [$axattd2, player_medikitd3    ] {self.weaponframe=6;};
  242. void()    player_medikitd3 =    [$axattd3, player_medikitd4    ] {self.weaponframe=7;W_FireMedikit();};
  243. void()    player_medikitd4 =    [$axattd4, player_run    ] {self.weaponframe=8;};
  244.  
  245. void()    player_bioweapon1 =    [$axatt1, player_bioweapon2    ] {self.weaponframe=1;};
  246. void()    player_bioweapon2 =    [$axatt2, player_bioweapon3    ] {self.weaponframe=2;};
  247. void()    player_bioweapon3 =    [$axatt3, player_bioweapon4    ] {self.weaponframe=3;W_FireBioweapon();};
  248. void()    player_bioweapon4 =    [$axatt4, player_run    ] {self.weaponframe=4;};
  249.  
  250. void()    player_bioweaponb1 =    [$axattb1, player_bioweaponb2    ] {self.weaponframe=5;};
  251. void()    player_bioweaponb2 =    [$axattb2, player_bioweaponb3    ] {self.weaponframe=6;};
  252. void()    player_bioweaponb3 =    [$axattb3, player_bioweaponb4    ] {self.weaponframe=7;W_FireBioweapon();};
  253. void()    player_bioweaponb4 =    [$axattb4, player_run    ] {self.weaponframe=8;};
  254.  
  255. void()    player_bioweaponc1 =    [$axattc1, player_bioweaponc2    ] {self.weaponframe=1;};
  256. void()    player_bioweaponc2 =    [$axattc2, player_bioweaponc3    ] {self.weaponframe=2;};
  257. void()    player_bioweaponc3 =    [$axattc3, player_bioweaponc4    ] {self.weaponframe=3;W_FireBioweapon();};
  258. void()    player_bioweaponc4 =    [$axattc4, player_run    ] {self.weaponframe=4;};
  259.  
  260. void()    player_bioweapond1 =    [$axattd1, player_bioweapond2    ] {self.weaponframe=5;};
  261. void()    player_bioweapond2 =    [$axattd2, player_bioweapond3    ] {self.weaponframe=6;};
  262. void()    player_bioweapond3 =    [$axattd3, player_bioweapond4    ] {self.weaponframe=7;W_FireBioweapon();};
  263. void()    player_bioweapond4 =    [$axattd4, player_run    ] {self.weaponframe=8;};
  264.  
  265. //============================================================================
  266.  
  267. void() player_nail1   =[$nailatt1, player_nail2  ] 
  268. {
  269.     self.effects = self.effects | EF_MUZZLEFLASH;
  270.  
  271.     if (!self.button0)
  272.         {player_run ();return;}
  273.     self.weaponframe = self.weaponframe + 1;
  274.     if (self.weaponframe == 9)
  275.         self.weaponframe = 1;
  276.     SuperDamageSound();
  277.     W_FireSpikes (4);
  278.     self.attack_finished = time + 0.2;
  279. };
  280. void() player_nail2   =[$nailatt2, player_nail1  ]
  281. {
  282.     self.effects = self.effects | EF_MUZZLEFLASH;
  283.  
  284.     if (!self.button0)
  285.         {player_run ();return;}
  286.     self.weaponframe = self.weaponframe + 1;
  287.     if (self.weaponframe == 9)
  288.         self.weaponframe = 1;
  289.     SuperDamageSound();
  290.     W_FireSpikes (-4);
  291.     self.attack_finished = time + 0.2;
  292. };
  293.  
  294. //============================================================================
  295. // Assault cannon stuff
  296. void() player_assaultcannon1   =[$nailatt1, player_assaultcannon2  ] 
  297. {
  298.     local string st;
  299.     local entity tcool;
  300.  
  301.     self.effects = self.effects | EF_MUZZLEFLASH;
  302.  
  303.     if ((!self.button0) || (self.ammo_shells < 1))
  304.     {
  305.         // Let him/her walk again
  306.         TeamFortress_SetSpeed();
  307.         stuffcmd(self, "v_idlescale 0\n");
  308.  
  309.         // Cool
  310.          sprint(self, "cooling...\n");
  311.         tcool = spawn();
  312.         tcool.owner = self;
  313.         tcool.classname = "timer";
  314.         tcool.nextthink = time + (self.heat * 4);
  315.         tcool.think = W_Cool_assault_cannon;
  316.  
  317.         self.weapon = W_BestWeapon ();
  318.         W_SetCurrentAmmo ();
  319.  
  320.         player_run ();
  321.         return;
  322.     }
  323.  
  324.     self.weaponframe = self.weaponframe + 1;
  325.     if (self.weaponframe == 9)
  326.         self.weaponframe = 1;
  327.     SuperDamageSound();
  328.     W_FireAssaultCannon();
  329.  
  330.     // Shake the screen
  331.     stuffcmd(self, "v_idlescale ");
  332.     if (self.heat < 5)
  333.         st = ftos(self.heat * 4);
  334.     else
  335.         st = "20";
  336.     stuffcmd(self, st);
  337.     stuffcmd(self, "\n");
  338.     self.attack_finished = time + 0.1;
  339. };
  340.  
  341. void() player_assaultcannon2   =[$nailatt2, player_assaultcannon1  ]
  342. {
  343.     local string st;
  344.     local entity tcool;
  345.  
  346.     self.effects = self.effects | EF_MUZZLEFLASH;
  347.  
  348.     if ((!self.button0) || (self.ammo_shells < 1))
  349.     {
  350.         // Let him/her walk again
  351.         TeamFortress_SetSpeed();
  352.         stuffcmd(self, "v_idlescale 0\n");
  353.  
  354.         // Cool
  355.          sprint(self, "cooling...\n");
  356.         tcool = spawn();
  357.         tcool.owner = self;
  358.         tcool.classname = "timer";
  359.         tcool.nextthink = time + (self.heat * 4);
  360.         tcool.think = W_Cool_assault_cannon;
  361.  
  362.         self.weapon = W_BestWeapon ();
  363.         W_SetCurrentAmmo ();
  364.  
  365.         player_run ();
  366.         return;
  367.     }
  368.  
  369.     self.weaponframe = self.weaponframe + 1;
  370.     if (self.weaponframe == 9)
  371.         self.weaponframe = 1;
  372.     SuperDamageSound();
  373.     W_FireAssaultCannon();
  374.  
  375.     // increase the heat of the cannon
  376.     self.heat = self.heat + 0.1;
  377.     // Shake the screen
  378.     stuffcmd(self, "v_idlescale 0\n");
  379.     stuffcmd(self, "bf\n");
  380.  
  381.     // Fire a tracer every few seconds
  382.     if ((self.heat / 5) == (ceil(self.heat / 5)))
  383.     {
  384.         sprint(self, "tracer\n");
  385.     }
  386.  
  387.     self.attack_finished = time + 0.1;
  388. };
  389.  
  390. //============================================================================
  391.  
  392. void() player_light1   =[$light1, player_light2  ] 
  393. {
  394.     self.effects = self.effects | EF_MUZZLEFLASH;
  395.  
  396.     if (!self.button0)
  397.         {player_run ();return;}
  398.     self.weaponframe = self.weaponframe + 1;
  399.     if (self.weaponframe == 5)
  400.         self.weaponframe = 1;
  401.     SuperDamageSound();
  402.     W_FireLightning();
  403.     self.attack_finished = time + 0.2;
  404. };
  405. void() player_light2   =[$light2, player_light1  ]
  406. {
  407.     self.effects = self.effects | EF_MUZZLEFLASH;
  408.  
  409.     if (!self.button0)
  410.         {player_run ();return;}
  411.     self.weaponframe = self.weaponframe + 1;
  412.     if (self.weaponframe == 5)
  413.         self.weaponframe = 1;
  414.     SuperDamageSound();
  415.     W_FireLightning();
  416.     self.attack_finished = time + 0.2;
  417. };
  418.  
  419. //============================================================================
  420.  
  421.  
  422. void() player_rocket1   =[$rockatt1, player_rocket2  ] {self.weaponframe=1;
  423. self.effects = self.effects | EF_MUZZLEFLASH;};
  424. void() player_rocket2   =[$rockatt2, player_rocket3  ] {self.weaponframe=2;};
  425. void() player_rocket3   =[$rockatt3, player_rocket4  ] {self.weaponframe=3;};
  426. void() player_rocket4   =[$rockatt4, player_rocket5  ] {self.weaponframe=4;};
  427. void() player_rocket5   =[$rockatt5, player_rocket6  ] {self.weaponframe=5;};
  428. void() player_rocket6   =[$rockatt6, player_run  ] {self.weaponframe=6;};
  429. void(float num_bubbles) DeathBubbles;
  430.  
  431. void() PainSound =
  432. {
  433. local float        rs;
  434.  
  435.     if (self.health < 0)
  436.         return;
  437.  
  438.     if (damage_attacker.classname == "teledeath")
  439.     {
  440.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  441.         return;
  442.     }
  443.  
  444. // water pain sounds
  445.     if (self.watertype == CONTENT_WATER && self.waterlevel == 3)
  446.     {
  447.         DeathBubbles(1);
  448.         if (random() > 0.5)
  449.             sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM);
  450.         else
  451.             sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM);
  452.         return;
  453.     }
  454.  
  455. // slime pain sounds
  456.     if (self.watertype == CONTENT_SLIME)
  457.     {
  458. // FIX ME    put in some steam here
  459.         if (random() > 0.5)
  460.             sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
  461.         else
  462.             sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
  463.         return;
  464.     }
  465.  
  466.     if (self.watertype == CONTENT_LAVA)
  467.     {
  468.         if (random() > 0.5)
  469.             sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
  470.         else
  471.             sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
  472.         return;
  473.     }
  474.  
  475.     if (self.pain_finished > time)
  476.     {
  477.         self.axhitme = 0;
  478.         return;
  479.     }
  480.     self.pain_finished = time + 0.5;
  481.  
  482. // don't make multiple pain sounds right after each other
  483.  
  484. // ax pain sound
  485.     if (self.axhitme == 1)
  486.     {
  487.         self.axhitme = 0;
  488.         sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM);
  489.         return;
  490.     }
  491.     
  492.  
  493.     rs = rint((random() * 5) + 1);
  494.  
  495.     self.noise = "";
  496.     if (rs == 1)
  497.         self.noise = "player/pain1.wav";
  498.     else if (rs == 2)
  499.         self.noise = "player/pain2.wav";
  500.     else if (rs == 3)
  501.         self.noise = "player/pain3.wav";
  502.     else if (rs == 4)
  503.         self.noise = "player/pain4.wav";
  504.     else if (rs == 5)
  505.         self.noise = "player/pain5.wav";
  506.     else
  507.         self.noise = "player/pain6.wav";
  508.  
  509.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  510.     return;
  511. };
  512.  
  513. void()    player_pain1 =    [    $pain1,    player_pain2    ] {PainSound();self.weaponframe=0;};
  514. void()    player_pain2 =    [    $pain2,    player_pain3    ] {};
  515. void()    player_pain3 =    [    $pain3,    player_pain4    ] {};
  516. void()    player_pain4 =    [    $pain4,    player_pain5    ] {};
  517. void()    player_pain5 =    [    $pain5,    player_pain6    ] {};
  518. void()    player_pain6 =    [    $pain6,    player_run    ] {};
  519.  
  520. void()    player_axpain1 =    [    $axpain1,    player_axpain2    ] {PainSound();self.weaponframe=0;};
  521. void()    player_axpain2 =    [    $axpain2,    player_axpain3    ] {};
  522. void()    player_axpain3 =    [    $axpain3,    player_axpain4    ] {};
  523. void()    player_axpain4 =    [    $axpain4,    player_axpain5    ] {};
  524. void()    player_axpain5 =    [    $axpain5,    player_axpain6    ] {};
  525. void()    player_axpain6 =    [    $axpain6,    player_run    ] {};
  526.  
  527. void() player_pain =
  528. {
  529.     if (self.weaponframe)
  530.         return;
  531.  
  532.     if (self.invisible_finished > time)
  533.         return;        // eyes don't have pain frames
  534.  
  535.     if (self.weapon == IT_AXE)
  536.         player_axpain1 ();
  537.     else
  538.         player_pain1 ();
  539. };
  540.  
  541. void() player_diea1;
  542. void() player_dieb1;
  543. void() player_diec1;
  544. void() player_died1;
  545. void() player_diee1;
  546. void() player_die_ax1;
  547.  
  548. void() DeathBubblesSpawn =
  549. {
  550. local entity    bubble;
  551.     if (self.owner.waterlevel != 3)
  552.         return;
  553.     bubble = spawn();
  554.     setmodel (bubble, "progs/s_bubble.spr");
  555.     setorigin (bubble, self.owner.origin + '0 0 24');
  556.     bubble.movetype = MOVETYPE_NOCLIP;
  557.     bubble.solid = SOLID_NOT;
  558.     bubble.velocity = '0 0 15';
  559.     bubble.nextthink = time + 0.5;
  560.     bubble.think = bubble_bob;
  561.     bubble.classname = "bubble";
  562.     bubble.frame = 0;
  563.     bubble.cnt = 0;
  564.     setsize (bubble, '-8 -8 -8', '8 8 8');
  565.     self.nextthink = time + 0.1;
  566.     self.think = DeathBubblesSpawn;
  567.     self.air_finished = self.air_finished + 1;
  568.     if (self.air_finished >= self.bubble_count)
  569.         remove(self);
  570. };
  571.  
  572. void(float num_bubbles) DeathBubbles =
  573. {
  574. local entity    bubble_spawner;
  575.     
  576.     bubble_spawner = spawn();
  577.     setorigin (bubble_spawner, self.origin);
  578.     bubble_spawner.movetype = MOVETYPE_NONE;
  579.     bubble_spawner.solid = SOLID_NOT;
  580.     bubble_spawner.nextthink = time + 0.1;
  581.     bubble_spawner.think = DeathBubblesSpawn;
  582.     bubble_spawner.air_finished = 0;
  583.     bubble_spawner.owner = self;
  584.     bubble_spawner.bubble_count = num_bubbles;
  585.     return;
  586. };
  587.  
  588.  
  589. void() DeathSound =
  590. {
  591. local float        rs;
  592.  
  593.     // water death sounds
  594.     if (self.waterlevel == 3)
  595.     {
  596.         DeathBubbles(20);
  597.         sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE);
  598.         return;
  599.     }
  600.     
  601.     rs = rint ((random() * 4) + 1);
  602.     if (rs == 1)
  603.         self.noise = "player/death1.wav";
  604.     if (rs == 2)
  605.         self.noise = "player/death2.wav";
  606.     if (rs == 3)
  607.         self.noise = "player/death3.wav";
  608.     if (rs == 4)
  609.         self.noise = "player/death4.wav";
  610.     if (rs == 5)
  611.         self.noise = "player/death5.wav";
  612.  
  613.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE);
  614.     return;
  615. };
  616.  
  617.  
  618. void() PlayerDead =
  619. {
  620.     self.nextthink = -1;
  621. // allow respawn after a certain time
  622.     self.deadflag = DEAD_DEAD;
  623. };
  624.  
  625. vector(float dm) VelocityForDamage =
  626. {
  627.     local vector v;
  628.  
  629.     v_x = 100 * crandom();
  630.     v_y = 100 * crandom();
  631.     v_z = 200 + 100 * random();
  632.  
  633.     if (dm > -50)
  634.     {
  635. //        dprint ("level 1\n");
  636.         v = v * 0.7;
  637.     }
  638.     else if (dm > -200)
  639.     {
  640. //        dprint ("level 3\n");
  641.         v = v * 2;
  642.     }
  643.     else
  644.         v = v * 10;
  645.  
  646.     return v;
  647. };
  648.  
  649. void(string gibname, float dm) ThrowGib =
  650. {
  651.     local    entity new;
  652.  
  653.     new = spawn();
  654.     new.origin = self.origin;
  655.     setmodel (new, gibname);
  656.     setsize (new, '0 0 0', '0 0 0');
  657.     new.velocity = VelocityForDamage (dm);
  658.     new.movetype = MOVETYPE_BOUNCE;
  659.     new.solid = SOLID_NOT;
  660.     new.avelocity_x = random()*600;
  661.     new.avelocity_y = random()*600;
  662.     new.avelocity_z = random()*600;
  663.     new.think = SUB_Remove;
  664.     new.ltime = time;
  665.     new.nextthink = time + 10 + random()*10;
  666.     new.frame = 0;
  667.     new.flags = 0;
  668. };
  669.  
  670. void(string gibname, float dm) ThrowHead =
  671. {
  672.     setmodel (self, gibname);
  673.     self.frame = 0;
  674.     self.nextthink = -1;
  675.     self.movetype = MOVETYPE_BOUNCE;
  676.     self.takedamage = DAMAGE_NO;
  677.     self.solid = SOLID_NOT;
  678.     self.view_ofs = '0 0 8';
  679.     setsize (self, '-16 -16 0', '16 16 56');
  680.     self.velocity = VelocityForDamage (dm);
  681.     self.origin_z = self.origin_z - 24;
  682.     self.flags = self.flags - (self.flags & FL_ONGROUND);
  683.     self.avelocity = crandom() * '0 600 0';
  684. };
  685.  
  686.  
  687. void() GibPlayer =
  688. {
  689.     ThrowHead ("progs/h_player.mdl", self.health);
  690.     ThrowGib ("progs/gib1.mdl", self.health);
  691.     ThrowGib ("progs/gib2.mdl", self.health);
  692.     ThrowGib ("progs/gib3.mdl", self.health);
  693.  
  694.     self.deadflag = DEAD_DEAD;
  695.  
  696.     if (damage_attacker.classname == "teledeath")
  697.     {
  698.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  699.         return;
  700.     }
  701.  
  702.     if (damage_attacker.classname == "teledeath2")
  703.     {
  704.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  705.         return;
  706.     }
  707.         
  708.     if (random() < 0.5)
  709.         sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE);
  710.     else
  711.         sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE);
  712. };
  713.  
  714. void() PlayerDie =
  715. {
  716.     local float     i;
  717.     
  718.     self.items = self.items - (self.items & IT_INVISIBILITY);
  719.     self.invisible_finished = 0;    // don't die as eyes
  720.     self.invincible_finished = 0;
  721.     self.super_damage_finished = 0;
  722.     self.radsuit_finished = 0;
  723.     self.modelindex = modelindex_player;    // don't use eyes
  724.  
  725.     // Remove all the timer entities for this player
  726.     TeamFortress_RemoveTimers();
  727.  
  728.     if (deathmatch || coop)
  729.         DropBackpack();
  730.     
  731.     self.weaponmodel="";
  732.     self.view_ofs = '0 0 -8';
  733.     self.deadflag = DEAD_DYING;
  734.     self.solid = SOLID_NOT;
  735.     self.flags = self.flags - (self.flags & FL_ONGROUND);
  736.     self.movetype = MOVETYPE_TOSS;
  737.     if (self.velocity_z < 10)
  738.         self.velocity_z = self.velocity_z + random()*300;
  739.  
  740.     if (self.health < -40)
  741.     {
  742.         GibPlayer ();
  743.         return;
  744.     }
  745.  
  746.     DeathSound();
  747.     
  748.     self.angles_x = 0;
  749.     self.angles_z = 0;
  750.  
  751.     if (self.weapon == IT_AXE)
  752.     {
  753.         player_die_ax1 ();
  754.         return;
  755.     }
  756.     
  757.     i = cvar("temp1");
  758.     if (!i)
  759.         i = 1 + floor(random()*6);
  760.     
  761.     if (i == 1)
  762.         player_diea1();
  763.     else if (i == 2)
  764.         player_dieb1();
  765.     else if (i == 3)
  766.         player_diec1();
  767.     else if (i == 4)
  768.         player_died1();
  769.     else
  770.         player_diee1();
  771.  
  772. };
  773.  
  774. void() set_suicide_frame =
  775. {    // used by kill command and diconnect command
  776.     if (self.model != "progs/player.mdl")
  777.         return;    // allready gibbed
  778.     self.frame = $deatha11;
  779.     self.solid = SOLID_NOT;
  780.     self.movetype = MOVETYPE_TOSS;
  781.     self.deadflag = DEAD_DEAD;
  782.     self.nextthink = -1;
  783. };
  784.  
  785.  
  786. void()    player_diea1    =    [    $deatha1,    player_diea2    ] {};
  787. void()    player_diea2    =    [    $deatha2,    player_diea3    ] {};
  788. void()    player_diea3    =    [    $deatha3,    player_diea4    ] {};
  789. void()    player_diea4    =    [    $deatha4,    player_diea5    ] {};
  790. void()    player_diea5    =    [    $deatha5,    player_diea6    ] {};
  791. void()    player_diea6    =    [    $deatha6,    player_diea7    ] {};
  792. void()    player_diea7    =    [    $deatha7,    player_diea8    ] {};
  793. void()    player_diea8    =    [    $deatha8,    player_diea9    ] {};
  794. void()    player_diea9    =    [    $deatha9,    player_diea10    ] {};
  795. void()    player_diea10    =    [    $deatha10,    player_diea11    ] {};
  796. void()    player_diea11    =    [    $deatha11,    player_diea11 ] {PlayerDead();};
  797.  
  798. void()    player_dieb1    =    [    $deathb1,    player_dieb2    ] {};
  799. void()    player_dieb2    =    [    $deathb2,    player_dieb3    ] {};
  800. void()    player_dieb3    =    [    $deathb3,    player_dieb4    ] {};
  801. void()    player_dieb4    =    [    $deathb4,    player_dieb5    ] {};
  802. void()    player_dieb5    =    [    $deathb5,    player_dieb6    ] {};
  803. void()    player_dieb6    =    [    $deathb6,    player_dieb7    ] {};
  804. void()    player_dieb7    =    [    $deathb7,    player_dieb8    ] {};
  805. void()    player_dieb8    =    [    $deathb8,    player_dieb9    ] {};
  806. void()    player_dieb9    =    [    $deathb9,    player_dieb9    ] {PlayerDead();};
  807.  
  808. void()    player_diec1    =    [    $deathc1,    player_diec2    ] {};
  809. void()    player_diec2    =    [    $deathc2,    player_diec3    ] {};
  810. void()    player_diec3    =    [    $deathc3,    player_diec4    ] {};
  811. void()    player_diec4    =    [    $deathc4,    player_diec5    ] {};
  812. void()    player_diec5    =    [    $deathc5,    player_diec6    ] {};
  813. void()    player_diec6    =    [    $deathc6,    player_diec7    ] {};
  814. void()    player_diec7    =    [    $deathc7,    player_diec8    ] {};
  815. void()    player_diec8    =    [    $deathc8,    player_diec9    ] {};
  816. void()    player_diec9    =    [    $deathc9,    player_diec10    ] {};
  817. void()    player_diec10    =    [    $deathc10,    player_diec11    ] {};
  818. void()    player_diec11    =    [    $deathc11,    player_diec12    ] {};
  819. void()    player_diec12    =    [    $deathc12,    player_diec13    ] {};
  820. void()    player_diec13    =    [    $deathc13,    player_diec14    ] {};
  821. void()    player_diec14    =    [    $deathc14,    player_diec15    ] {};
  822. void()    player_diec15    =    [    $deathc15,    player_diec15 ] {PlayerDead();};
  823.  
  824. void()    player_died1    =    [    $deathd1,    player_died2    ] {};
  825. void()    player_died2    =    [    $deathd2,    player_died3    ] {};
  826. void()    player_died3    =    [    $deathd3,    player_died4    ] {};
  827. void()    player_died4    =    [    $deathd4,    player_died5    ] {};
  828. void()    player_died5    =    [    $deathd5,    player_died6    ] {};
  829. void()    player_died6    =    [    $deathd6,    player_died7    ] {};
  830. void()    player_died7    =    [    $deathd7,    player_died8    ] {};
  831. void()    player_died8    =    [    $deathd8,    player_died9    ] {};
  832. void()    player_died9    =    [    $deathd9,    player_died9    ] {PlayerDead();};
  833.  
  834. void()    player_diee1    =    [    $deathe1,    player_diee2    ] {};
  835. void()    player_diee2    =    [    $deathe2,    player_diee3    ] {};
  836. void()    player_diee3    =    [    $deathe3,    player_diee4    ] {};
  837. void()    player_diee4    =    [    $deathe4,    player_diee5    ] {};
  838. void()    player_diee5    =    [    $deathe5,    player_diee6    ] {};
  839. void()    player_diee6    =    [    $deathe6,    player_diee7    ] {};
  840. void()    player_diee7    =    [    $deathe7,    player_diee8    ] {};
  841. void()    player_diee8    =    [    $deathe8,    player_diee9    ] {};
  842. void()    player_diee9    =    [    $deathe9,    player_diee9    ] {PlayerDead();};
  843.  
  844. void()    player_die_ax1    =    [    $axdeth1,    player_die_ax2    ] {};
  845. void()    player_die_ax2    =    [    $axdeth2,    player_die_ax3    ] {};
  846. void()    player_die_ax3    =    [    $axdeth3,    player_die_ax4    ] {};
  847. void()    player_die_ax4    =    [    $axdeth4,    player_die_ax5    ] {};
  848. void()    player_die_ax5    =    [    $axdeth5,    player_die_ax6    ] {};
  849. void()    player_die_ax6    =    [    $axdeth6,    player_die_ax7    ] {};
  850. void()    player_die_ax7    =    [    $axdeth7,    player_die_ax8    ] {};
  851. void()    player_die_ax8    =    [    $axdeth8,    player_die_ax9    ] {};
  852. void()    player_die_ax9    =    [    $axdeth9,    player_die_ax9    ] {PlayerDead();};
  853.